<template>
    <Modal :mask-closable="false" v-model="opened" :title="title" width="80%" class="modal-content-layout">
        <div class="t-r mb16">
            <!--               <span class="creatBtnright" @click="exportExcel">-->
            <!--                   <span><Icon type="ios-cloud-download-outline" /></span>      -->
            <!--                   <span class="rightbtn">{{$t('common.Export')}}</span>-->
            <!--               </span>-->
            <Button @click="exportExcel" type="primary">{{ $t('common.Export') }}</Button>
        </div>

        <comment-score v-if="opened" @onLoad="onLoad" :dmsDeviceScoreConfigId="dmsDeviceScoreConfigId"></comment-score>

        <div slot="footer">
            <Button type="default" @click="close">{{ $t('common.Cancle') }}</Button>
            <Button type="primary" :loading="submitLoading" @click="submit">{{ $t('maintenance.Confirmed') }}</Button>
        </div>

        <Spin size="large" fix v-if="spinShow"></Spin>
    </Modal>
</template>

<script>
import { exportExcel } from "@/api/dev-basic/score-config";
import CommentScore from "@/components/commentscore";
import fileDownload from 'js-file-download'
export default {
    name: 'addScoreConfig',
    components: {
        CommentScore
    },
    data() {
        return {
            dmsDeviceScoreConfigId: '',
            submitLoading: false,
            spinShow: true,
            opened: false,
            title: '',
            tableData: [],
            tableColumn: [{
                title: 'Date',
                key: 'date'
            }, {
                title: 'Name',
                key: 'name'
            }, {
                title: 'Age',
                key: 'age'
            }, {
                title: 'Address',
                key: 'address'
            }]
        }
    },
    methods: {
        open(title, dmsDeviceScoreConfigId) {
            this.spinShow = true;
            this.title = title;
            this.dmsDeviceScoreConfigId = dmsDeviceScoreConfigId + '';
            this.opened = true;
        },
        close() {
            this.opened = false;
        },
        onLoad() {
            this.spinShow = false;
        },
        exportExcel() {
            let params = {
                dmsDeviceScoreConfigId: this.dmsDeviceScoreConfigId
            }
            exportExcel(params).then(res => {
                fileDownload(res, '设备评分表.xlsx');
            })
        },
        submit() {
            this.close()
        },
        handleSpan() {

        }
    }
}
</script>
